package com.sskj.login.presenter;

import com.alibaba.android.arouter.launcher.ARouter;
import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.router.provider.SendSmsProvider;
import com.sskj.login.http.HttpConfig;
import com.sskj.login.ui.activity.RegisterActivity;


public class RegisterActivityPresenter extends BasePresenter<RegisterActivity> {

    public void sendCode(String mcode, String account) {
        SendSmsProvider navigation = ARouter.getInstance().navigation(SendSmsProvider.class);
        navigation.send(this,account, mcode,"10", new SendSmsProvider.OnSend() {
            @Override
            public void onSuccess() {
                mView.sendCheckCodeSuccess();
            }
            @Override
            public void onFail() {
                mView.sendCheckCodeFail();
            }
        });
    }

    /**
     * 手机号注册
     *
     * @param mcode  区号
     * @param mobile 手机号/邮箱号
     * @param code   验证码
     * @param opwd   密码
     * @param opwd1  重复密码
     * @param tjuser 推荐码/邀请码
     * @return
     */
    public void register(String mcode, String mobile, String code, String opwd, String opwd1, String tjuser) {
        httpService.register(mcode, mobile, code, opwd, opwd1, tjuser)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.registerSuccess();
                        }
                    }
                });
    }


}
